CHIBI_SCHEME_URL=\
http://chibi-scheme.googlecode.com/files/chibi-scheme-0.5.3.tgz

if ! test -d chibi-scheme-*/
then
  curl -s $CHIBI_SCHEME_URL | tar -xzf -
fi

for dir in chibi-scheme-*
do

  for file in \
    $(find "$dir" -name "*.scm" -print) \
    $(find "$dir" -name "*.sld" -print) 
  do

    echo $file

    cat <"$file" | expand | grep -v "^ *;" >original-version
    
    chibi-scheme scheme-indent.scm <"$file" | grep -v "^ *;" >r7rs-version

    if ! diff -w original-version r7rs-version
    then
			exec 1>&2
      echo "ERROR: formatting failed."
			echo
			cat /tmp/test.out
      exit 1
    fi

    rm original-version r7rs-version

  done
  
done >/tmp/test.out

echo PASSED
echo
cat /tmp/test.out
